package com.iweb.user.controller;

import com.iweb.user.model.User;
import com.iweb.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
@CrossOrigin
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping
    public int addOne(@ModelAttribute User user){
        System.out.println("增加");
        return userService.addOne(user);
    }
    @GetMapping("/login")
    public int selectOne(@ModelAttribute User user){
        System.out.println("登录");
        return userService.selectOne(user);
    }
    @GetMapping("/{user_id}")
    public User selectById(@PathVariable int user_id){
        System.out.println("用户个人信息");
        return userService.selectById(user_id);
    }
    @PutMapping
    public int editOne(@ModelAttribute User user){
        System.out.println("编辑");
        return userService.editOne(user);
    }

}
